package com.huayi.gg.activity;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.huayi.gg.R;


public class AppStart extends Activity {
    private SharedPreferences sp;
    private LinearLayout app_start_view;
    private  String TAG="AppStart";

    Dialog dialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final View view = View.inflate(this, R.layout.app_start, null);
        setContentView(view);
        app_start_view = (LinearLayout) findViewById(R.id.app_start_view);






        // 渐变展示启动屏
        AlphaAnimation aa = new AlphaAnimation(0.5f, 1.0f);
        aa.setDuration(3000);
        view.startAnimation(aa);
        aa.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation arg0) {
                redirectTo();

            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }
        });
    }



    Drawable bitmap2Drawable(Bitmap bitmap) {
        return new BitmapDrawable(bitmap);
    }

    private void redirectTo() {

        int screenWidth1 = getWindowManager().getDefaultDisplay().getWidth();
        // 屏幕高(像素，如：800p)
        int screenHeight1 = getWindowManager().getDefaultDisplay().getHeight();
        Log.e(TAG, "高度1==============>" + screenHeight1 + " px");
        Log.e(TAG, "宽度1==============>" + screenWidth1 + " px");


        //Toast.makeText(AppStart.this,"高"+screenHeight1+"宽"+screenWidth1,Toast.LENGTH_LONG).show();

        if(screenHeight1>screenWidth1){
            Intent intent = new Intent(this, MainActivity.class);
            startActivity(intent);
        }else{
            Intent intent = new Intent(this, KuanActivity.class);
            startActivity(intent);
        }



        this.finish();

    }


    @Override
    protected void onResume() {



        super.onResume();
    }


}